# -*- coding: utf-8 -*-
from datetime import timedelta

from jms.ods.tms.yl_tmsnew_tms_vehicle_point import jms_ods__yl_tmsnew_tms_vehicle_point
from utils.operators.cluster_for_spark_sql_operator import SparkSqlOperator

jms_dim__dim_yl_tmsnew_tms_vehicle_point_base_dt_new = SparkSqlOperator(
    task_id='jms_dim__dim_yl_tmsnew_tms_vehicle_point_base_dt_new',
    task_concurrency=1,
    pool_slots=2,
    master='yarn',
    name='jms_dim__dim_yl_tmsnew_tms_vehicle_point_base_dt_new_{{ execution_date | date_add(1) | cst_ds }}',
    sql='jms/dim/back/dim_yl_tmsnew_tms_vehicle_point_base_dt_new/execute.sql',
    executor_cores=2 , 
    executor_memory='2G' , 
    email=['rabie.zhuang@jtexpress.com', 'yl_bigdata@yl-scm.com'],
    num_executors=2 , 
    conf={'spark.dynamicAllocation.enabled': 'true',  # 动态资源开启
          'spark.shuffle.service.enabled': 'true',  # 动态资源 Shuffle 服务开启
        'spark.dynamicAllocation.maxExecutors'             : 2 , 
          'spark.dynamicAllocation.cachedExecutorIdleTimeout': 60,  # 动态资源自动释放闲置 Executor 的超时时间(s)
          'spark.sql.sources.partitionOverwriteMode': 'dynamic',  # 允许删改已存在的分区
        'spark.executor.memoryOverhead'             : '1G' , 
          'spark.sql.shuffle.partitions': 20,
          },
    # hiveconf={'hive.exec.dynamic.partition': 'true',  # 动态分区
    #           'hive.exec.dynamic.partition.mode': 'nonstrict',
    #           'hive.exec.max.dynamic.partitions': 20,  # 每天生成 20 个分区
    #           'hive.exec.max.dynamic.partitions.pernode': 20,  # 每天生成 20 个分区
    #           },
    yarn_queue='pro',
    execution_timeout=timedelta(minutes=30),
)

jms_dim__dim_yl_tmsnew_tms_vehicle_point_base_dt_new << jms_ods__yl_tmsnew_tms_vehicle_point
